#include <srts/stratego.h>
#include <stratego-lib/stratego-lib.h>
void init_constructors (void)
{
}
static Symbol sym_Nil_0;
static Symbol sym_None_0;
static Symbol sym_TypeName_2;
static Symbol sym_PointerOf_1;
static Symbol sym_Pointer_2;
static Symbol sym_Some_1;
static Symbol sym_Cons_2;
static void init_module_constructors (void)
{
sym_Nil_0 = ATmakeSymbol("Nil", 0, ATfalse);
ATprotectSymbol(sym_Nil_0);
sym_None_0 = ATmakeSymbol("None", 0, ATfalse);
ATprotectSymbol(sym_None_0);
sym_TypeName_2 = ATmakeSymbol("TypeName", 2, ATfalse);
ATprotectSymbol(sym_TypeName_2);
sym_PointerOf_1 = ATmakeSymbol("PointerOf", 1, ATfalse);
ATprotectSymbol(sym_PointerOf_1);
sym_Pointer_2 = ATmakeSymbol("Pointer", 2, ATfalse);
ATprotectSymbol(sym_Pointer_2);
sym_Some_1 = ATmakeSymbol("Some", 1, ATfalse);
ATprotectSymbol(sym_Some_1);
sym_Cons_2 = ATmakeSymbol("Cons", 2, ATfalse);
ATprotectSymbol(sym_Cons_2);
}
static ATerm term1;
static ATerm term0;
static void init_module_constant_terms (void)
{
ATprotect(&(term0));
term0 = (ATerm) ATmakeAppl(sym_None_0);
ATprotect(&(term1));
term1 = term0;
}
#include <srts/init-stratego-application.h>
extern const char * __tracing_table [];
extern unsigned short __tracing_table_counter;
ATerm io_wrap_1_0 (StrSL sl, StrCL a_41, ATerm t);
ATerm Strippointer_0_0 (StrSL sl, ATerm t);
ATerm main_0_0 (StrSL sl, ATerm t);
ATerm Strippointer_0_0 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "Strippointer_0_0";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
{
ATerm trm0 = t;
ATerm t_16 = NULL;
if(match_cons(t, sym_TypeName_2))
{
t_16 = ATgetArgument(t, 0);
{
ATerm trm1 = ATgetArgument(t, 1);
if(!(match_cons(trm1, sym_None_0)))
goto label1 ;
}
}
else
goto label1 ;
t = (ATerm) ATmakeAppl(sym_TypeName_2, t_16, term1);
goto label0 ;
label1 :
t = trm0;
{
ATerm trm2 = t;
ATerm s_16 = NULL;
if(match_cons(t, sym_TypeName_2))
{
s_16 = ATgetArgument(t, 0);
{
ATerm trm3 = ATgetArgument(t, 1);
if(match_cons(trm3, sym_Some_1))
{
ATerm trm4 = ATgetArgument(trm3, 0);
if(match_cons(trm4, sym_Pointer_2))
{
ATerm trm5 = ATgetArgument(trm4, 0);
if(((ATgetType(trm5) == AT_LIST) && !(ATisEmpty(trm5))))
{
ATerm trm6 = ATgetFirst((ATermList) trm5);
if(match_cons(trm6, sym_PointerOf_1))
{
ATerm trm7 = ATgetArgument(trm6, 0);
if(!(((ATgetType(trm7) == AT_LIST) && ATisEmpty(trm7))))
goto label2 ;
}
else
goto label2 ;
{
ATerm trm8 = (ATerm) ATgetNext((ATermList) trm5);
if(!(((ATgetType(trm8) == AT_LIST) && ATisEmpty(trm8))))
goto label2 ;
}
}
else
goto label2 ;
{
ATerm trm9 = ATgetArgument(trm4, 1);
if(!(match_cons(trm9, sym_None_0)))
goto label2 ;
}
}
else
goto label2 ;
}
else
goto label2 ;
}
}
else
goto label2 ;
t = (ATerm) ATmakeAppl(sym_TypeName_2, s_16, term1);
goto label0 ;
label2 :
t = trm2;
{
ATerm q_16 = NULL,r_16 = NULL;
if(match_cons(t, sym_TypeName_2))
{
q_16 = ATgetArgument(t, 0);
{
ATerm trm10 = ATgetArgument(t, 1);
if(match_cons(trm10, sym_Some_1))
{
ATerm trm11 = ATgetArgument(trm10, 0);
if(match_cons(trm11, sym_Pointer_2))
{
ATerm trm12 = ATgetArgument(trm11, 0);
if(((ATgetType(trm12) == AT_LIST) && !(ATisEmpty(trm12))))
{
ATerm trm13 = ATgetFirst((ATermList) trm12);
if(match_cons(trm13, sym_PointerOf_1))
{
ATerm trm14 = ATgetArgument(trm13, 0);
if(!(((ATgetType(trm14) == AT_LIST) && ATisEmpty(trm14))))
goto fail1 ;
}
else
goto fail1 ;
r_16 = (ATerm) ATgetNext((ATermList) trm12);
}
else
goto fail1 ;
{
ATerm trm15 = ATgetArgument(trm11, 1);
if(!(match_cons(trm15, sym_None_0)))
goto fail1 ;
}
}
else
goto fail1 ;
}
else
goto fail1 ;
}
}
else
goto fail1 ;
t = (ATerm) ATmakeAppl(sym_TypeName_2, q_16, (ATerm) ATmakeAppl(sym_Some_1, (ATerm) ATmakeAppl(sym_Pointer_2, r_16, term1)));
goto label0 ;
}
}
label0 :
;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail1 :
--__tracing_table_counter;
return(NULL);
}
ATerm main_0_0 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "main_0_0";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
{
struct str_closure l_163 = { &(Strippointer_0_0) , sl };
StrCL lifted0_cl = &(l_163);
t = io_wrap_1_0(sl, lifted0_cl, t);
if((t == NULL))
goto fail0 ;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail0 :
--__tracing_table_counter;
return(NULL);
}
static void register_strategies (void)
{
int initial_size = 117;
int max_load = 75;
struct str_closure * closures;
int closures_index = 0;
if((strategy_table == NULL))
strategy_table = ATtableCreate(initial_size, max_load);
closures = (struct str_closure*) malloc((sizeof(struct str_closure) * 3));
if((closures == NULL))
{
perror("malloc error for registration of dynamic strategies");
exit(1);
}
closures[closures_index].fun = &(io_wrap_1_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("io_wrap_1_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(Strippointer_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("Strippointer_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(main_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("main_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
}
int main (int argc, char * argv [])
{
ATerm out_term;
ATermList in_term;
int i;
ATinit(argc, argv, &(out_term));
init_constructors();
in_term = ATempty;
for ( i = (argc - 1) ; (i >= 0) ; i-- )
{
in_term = ATinsert(in_term, (ATerm) ATmakeAppl0(ATmakeSymbol(argv[i], 0, ATtrue)));
}
SRTS_stratego_initialize();
memset(__tracing_table, 0, (sizeof(unsigned short) * TRACING_TABLE_SIZE));
__tracing_table_counter = 0;
register_strategies();
out_term = main_0_0(NULL, (ATerm) in_term);
if((out_term != NULL))
{
ATfprintf(stdout, "%t\n", out_term);
exit(0);
}
else
{
ATfprintf(stderr, "%s: rewriting failed, trace:\n", argv[0]);
for ( i = 0 ; (__tracing_table[i] && (i < TRACING_TABLE_SIZE)) ; i++ )
ATfprintf(stderr, "\t%s\n", __tracing_table[i]);
exit(1);
}
}
